package com.project.controller;

import com.project.bean.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("thy")
public class ThymeleafController {

    @RequestMapping("test")
    public String test(HttpServletRequest request){
        //绑定共享数据
        request.setAttribute("name","张无忌");
        request.setAttribute("age",20);

        request.setAttribute("user",new UserBean(1,"李典", LocalDate.parse("2000-01-02")));

        List<UserBean> list = new ArrayList<>();
        list.add(new UserBean(2,"曹操", LocalDate.parse("2002-05-15")) );
        list.add(new UserBean(6,"张飞", LocalDate.parse("2004-11-09")) );
        list.add(new UserBean(3,"赵云", LocalDate.parse("2001-10-01")) );
        list.add(new UserBean(8,"关羽", LocalDate.parse("2003-08-24")) );
        request.setAttribute("list",list);
        return "/index.html";
    }
}
